home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / gen_vid / scrn_jb.com / D2HEX.ASM < prev    next >
Encoding:
Assembly Source File  |  1988-08-22  |  2.1 KB  |  126 lines

  1. ;
  2. ;this program tests the d2_hex subroutine
  3. ;
  4. ;           written by
  5. ;      John O. Battle, N4OE
  6. ;         c/s 73547,3346
  7. ;    732A Holcomb Bridge Road
  8. ;       Norcross, GA 30071
  9. ;         (404) 449-8536
  10. ;
  11. page      62,132       
  12.   
  13. cseg    segment    para public 'code'  
  14.     assume    cs:cseg,ds:cseg,es:cseg,ss:cseg  
  15.     org    100h  
  16.   
  17. begin:      
  18.  
  19. tester    proc    near 
  20.     assume    cs:cseg,ds:cseg
  21.     mov    bx,cs
  22.     mov    ds,bx
  23.     mov    ax,0
  24.     mov    bx,0
  25.     mov    dx,0
  26.     mov    cx,17
  27. tt_1:    push    ax      ;arg3 value
  28.     push    bx      ;arg2 col
  29.     push    dx      ;arg1 line
  30.     call    d2_hex
  31.     add    sp,6
  32.     inc    dx      ;line
  33.     inc    bx      ;col
  34.     inc    bx
  35.     inc    bx
  36.     inc    ax      ;value
  37.     loop    tt_1
  38.     int    20h
  39. tester    endp
  40.  
  41. daz    proc    near
  42. ;
  43. ;This function prints an ASCIIZ string to the monochrome screen.
  44. ;
  45. daz    endp
  46.  
  47.  
  48. d2_hex    proc    near
  49. ;
  50. ;This subroutine writes hex values to the monochrome screen.
  51. ;The value is first pushed onto the stack, then the
  52. ;screen line and column numbers are pushed.
  53. ;Next, the function is called, and finally, the stack  is fixed.
  54. ;
  55. ;    push    value
  56. ;    push    line
  57. ;    push    column
  58. ;    call    d2
  59. ;    add    sp,6        ;fix stack
  60. ;
  61.     push    ds        ;10 pushes in all
  62.     push    es
  63.     push    ax
  64.     push    bx
  65.     push    cx
  66.     push    dx
  67.     push    si
  68.     push    di
  69.     push    bp
  70.     pushf
  71.  
  72.     mov    bp,sp        ;get args from stack
  73.     mov    ax,[bp+22]    ;arg 1 (2*10 pushes + 2*1)
  74.                 ;screen line number
  75.     mov    ah,0
  76.     mov    bx,80
  77.     mul    bx
  78.     mov    bx,[bp+24]    ;arg 2 (2*10 pushes + 2*2)
  79.     add    ax,bx        ;screen column number
  80.     mov    dx,ax
  81.     shl    dx,1        ;multiply by two
  82.     mov    di,dx
  83.     mov    bl,[bp+26]    ;arg 3 (2*10 pushes + 2*3)
  84.     push    bx        ;value of number to display
  85.     mov    dl,bl
  86.     mov    cl,4
  87.     shr    dl,cl        ;get upper nibble
  88.     add    dl,30h        ;convert to ascii
  89.     cmp    dl,03ah        ;greater than 9?
  90.     jl    dx_1
  91.     add    dl,7        ;yes, then add 7
  92. dx_1:    
  93.     mov    dh,7
  94.     mov    bx,0b000h    ;monochrome display memory segment
  95.     mov    ds,bx
  96.     mov    ds:[di],dx    ;send to screen
  97.     pop    bx
  98.     mov    dl,bl
  99.     and    dl,0fh
  100.     add    dl,30h
  101.     cmp    dl,03ah
  102.     jl    dx_2
  103.     add    dl,7
  104. dx_2:    
  105.     mov    dh,7
  106.     mov    bx,0b000h    ;monochrome display memory segment
  107.     mov    ds,bx
  108.     mov    ds:[di+2],dx    
  109.  
  110.     popf
  111.     pop    bp
  112.     pop    di
  113.     pop    si
  114.     pop    dx
  115.     pop    cx
  116.     pop    bx
  117.     pop    ax
  118.     pop    es
  119.     pop    ds
  120.     ret
  121.  
  122. d2_hex    endp        
  123.  
  124. cseg    ends 
  125.     end    begin 
  126.